﻿'in this file, we store all events
Partial Public Class Manager
    Friend Shared Sub OnLogEvent(ByVal text As String)
        Framework.Log.Provider.LogInformation(text)
    End Sub
    Friend Shared Sub OnLogEvent(ByVal text As String, ByVal exception As Exception)
        Framework.Log.Provider.LogError(text, exception)
    End Sub

    Public Shared Event HashProgress(ByVal filePath As String, ByVal percent As Integer, ByVal bytesPerSecond As Integer)
    Friend Shared Sub OnHashProgress(ByVal filePath As String, ByVal percent As Integer, ByVal bytesPerSecond As Integer)
        Framework.Threading.Invoke(AddressOf OnHashProgress_Callback, filePath, percent, bytesPerSecond)
    End Sub
    Private Shared Sub OnHashProgress_Callback(ByVal filePath As String, ByVal percent As Integer, ByVal bytesPerSecond As Integer)
        RaiseEvent HashProgress(filePath, percent, bytesPerSecond)
    End Sub
    Public Shared Event HashFinished(ByVal filePath As String)
    Friend Shared Sub OnHashFinished(ByVal filePath As String)
        Framework.Threading.Invoke(AddressOf OnHashFinished_Callback, filePath)
    End Sub
    Private Shared Sub OnHashFinished_Callback(ByVal filePath As String)
        RaiseEvent HashFinished(filePath)
    End Sub

    Public Shared Event ScanShareStarting(ByVal share As Entities.Share)
    Friend Shared Sub OnScanShareStarting(ByVal share As Entities.Share)
        Framework.Threading.Invoke(AddressOf OnScanShareStarting_Callback, share)
    End Sub
    Private Shared Sub OnScanShareStarting_Callback(ByVal share As Entities.Share)
        RaiseEvent ScanShareStarting(share)
    End Sub
    Public Shared Event ScanShareCompleted(ByVal share As Entities.Share)
    Friend Shared Sub OnScanShareCompleted(ByVal share As Entities.Share)
        Framework.Threading.Invoke(AddressOf OnScanShareCompleted_Callback, share)
    End Sub
    Private Shared Sub OnScanShareCompleted_Callback(ByVal share As Entities.Share)
        RaiseEvent ScanShareCompleted(share)
    End Sub
    Public Shared Event ScanShareProgress(ByVal share As Entities.Share, ByVal info As String)
    Friend Shared Sub OnScanShareProgress(ByVal share As Entities.Share, ByVal info As String)
        Framework.Threading.Invoke(AddressOf OnScanShareProgress_Callback, share, info)
    End Sub
    Private Shared Sub OnScanShareProgress_Callback(ByVal share As Entities.Share, ByVal info As String)
        RaiseEvent ScanShareProgress(share, info)
    End Sub

    Public Shared Event PartUploaded(ByVal node As Framework.Net.Node, ByVal filePath As String, ByVal partId As Integer)
    Friend Shared Sub OnPartUploaded(ByVal node As Framework.Net.Node, ByVal filePath As String, ByVal partId As Integer)
        Framework.Threading.Invoke(AddressOf OnPartUploaded_Callback, node, filePath, partId)
    End Sub
    Private Shared Sub OnPartUploaded_Callback(ByVal node As Framework.Net.Node, ByVal filePath As String, ByVal partId As Integer)
        RaiseEvent PartUploaded(node, filePath, partId)
    End Sub

    Public Shared Event FileSysWatcherTrace(ByVal watcher As String, ByVal [event] As String, ByVal path As String, ByVal ignored As Boolean)
    Friend Shared Sub OnFileSysWatcherTrace(ByVal watcher As String, ByVal [event] As String, ByVal path As String, ByVal ignored As Boolean)
        Framework.Threading.Invoke(AddressOf OnFileSysWatcherTrace_Callback, watcher, [event], path, ignored)
    End Sub
    Private Shared Sub OnFileSysWatcherTrace_Callback(ByVal watcher As String, ByVal [event] As String, ByVal path As String, ByVal ignored As Boolean)
        RaiseEvent FileSysWatcherTrace(watcher, [event], path, ignored)
    End Sub

End Class
